//-------------------------------------------------------------------------------------------------------------------------------------
//-------MMMM----MMMMM----MMMMMMMMM-MMMMMMMM------MMMM----MMMMMMMM---MMM---MMMMMMM--------MMMMMM-----MMMMM----MMMMMMMM---MMMMMMMMM-----
//---------MM--MM-----MM--MM--------MM------MM---MM--MM---MM-----MM---M--MM-------------MM-----MM--MM-----MM--MM------MM-MM------------
//---------MM-MM-------MM-MM--------MM------MM--MM----MM--MM-----MM------MM------------MM---------MM-------MM-MM------MM-MM------------
//---------MM-MM-------MM-MMMMMMMM--MM------MM-MM------MM-MMMMMMMM--------MMMMMM-------MM---------MM-------MM-MM------MM-MMMMMMMM------
//--MM-----MM-MM-------MM-MM--------MM------MM-MM-MMMM-MM-MM-MM-----------------MM-----MM---------MM-------MM-MM------MM-MM------------
//--MM-----MM--MM-----MM--MM--------MM------MM-MM------MM-MM--MM----------------MM------MM-----MM--MM-----MM--MM------MM-MM------------
//---MMMMMM------MMMMM----MMMMMMMMM-MMMMMMMM---MM------MM-MM----MMM------MMMMMMM----------MMMMMM-----MMMMM----MMMMMMMM---MMMMMMMMM-----
//-------------------------------------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------\\
//                                                                         \\
//    MMMMMMMM MM    MM  MMMMMM  MM    MM    MM    MM  MMMMMM  MM    MM    \\
//    MM       MM    MM MM    MM MM   MM      MM  MM  MM    MM MM    MM    \\
//    MM       MM    MM MM       MM  MM        MMMM   MM    MM MM    MM    \\
//    MMMMMMM  MM    MM MM       MMMMM          MM    MM    MM MM    MM    \\
//    MM       MM    MM MM       MM  MM         MM    MM    MM MM    MM    \\
//    MM       MM    MM MM    MM MM   MM        MM    MM    MM MM    MM    \\
//    MM        MMMMMM   MMMMMM  MM    MM       MM     MMMMMM   MMMMMM     \\
//                                                                         \\
//-------------------------------------------------------------------------\\

var __o__ = 0;

var globalModule = globalModule || {};
globalModule = (function(){
	var pn = location.pathname
		,flagObj = {
			popAdImgFlag : parseInt(localStorage.popAdImgFlag) || 0
			,noviceFlag : parseInt(localStorage.noviceFlag) || 0
			,userInfoFlag : parseInt(localStorage.userInfoFlag) || 0
		}
	;

	// all.exitBtn = $('.theUserExit');
	// all.popLayerCloseBtn = $('.popLayer').find('.close').find('label[for="popLayer"]');
	// all.headerMresAddBtn = $('.header.m').find('.resAdd').find('a');


	return {
		root : function(){
			var str = '';
			if(localStorage.userType){
				if(localStorage.userType == 2){str = '/companyHome'}
				else if(localStorage.userType == 1){str = '/websiteHome'}
			}else{
				if(/companyHome/ig.test(pn)){str = '/companyHome'}
				else if(/websiteHome/ig.test(pn)){str = '/websiteHome'}
			}
			return str;
		}

		,wapRoot : function(){
			var str = '';
			if(/wap/g.test(pn) && /companyHome/g.test(pn)){str = '/wap/companyHome'}
			else if(/wap/g.test(pn) && /websiteHome/g.test(pn)){str = '/wap/websiteHome'}
			return str;
		}

		,userType : function(){
			var str = '';
			if(/companyHome/g.test(pn)){str = 2}
			if(/websiteHome/g.test(pn)){str = 1}
			return str;
		}

		,homeType : function(){
			var str = 'all';
			if(/companyHome/g.test(pn)){str = 'company'}
			else if(/websiteHome/g.test(pn)){str = 'website'}
			return str;
		}

		,openwx : 'http://open.weixin.qq.com/qr/code?username='
		,defaultTx : '/front/public/images/defaultTx.jpg'

		//判断浏览器版本事件
		,boswers : function(){
			var ua = navigator.userAgent ,boswer = '' ,theTip = ''
				,str1 = '温馨提醒：您当前为' ,str2 = '，版本过低，存在安全风险，'
				,maxthon = '<a href="http://www.maxthon.cn/" target="_blank">建议升级遨游5</a>'
				,sorry = '<a href="/front/commons/sorry/index.jsp" target="_blank">建议升级浏览器</a>'
			;
			if(ua.indexOf('WOW64; SLCC2')>-1){boswer = 'IE7'}
			if(ua.indexOf('Trident/4.0')>-1){boswer = 'IE8'}
			if(ua.indexOf('Maxthon/4')>-1){boswer = 'Maxthon4'}
			if(boswer == 'Maxthon4'){theTip  = '<div class="top-tip-boswer">'+str1+'遨游4'+str2+maxthon+'</div>'}
			if(boswer == 'IE7'){theTip  = '<div class="top-tip-boswer">'+str1+'IE7'+str2+sorry+'</div>'}
			if(boswer == 'IE8'){theTip  = '<div class="top-tip-boswer">'+str1+'IE8'+str2+sorry+'</div>'}
			$(theTip).prependTo('body');
		}

		// *yzm*cr*
		//时间戳转换为日期
		,timeToDate : function(n,str){
			var date = '';
			if(n){
				n = parseInt(n);
				var dd = new Date(n)
					,y = dd.getFullYear() ,M = dd.getMonth()+1 ,d = dd.getDate()
					,h = dd.getHours() ,m = dd.getMinutes() ,s = dd.getSeconds()
					,ny = new Date().getFullYear()
				;
				M < 10 && (M = '0'+M), d < 10 && (d = '0'+d),
				h < 10 && (h = '0'+h), m < 10 && (m = '0'+m), s < 10 && (s = '0'+s);
				if(str){
					if(str == 'ymdhm'){date = y+'-'+M+'-'+d+' '+h+':'+m}
					else if(str == 'y_mdhms'){
						if(y == ny){date = M+'-'+d+' '+h+':'+m+':'+s}
						else{date = y+'-'+M+'-'+d+' '+h+':'+m+':'+s}
					}
					else if(str == 'y_mdhm'){
						if(y == ny){date = M+'-'+d+' '+h+':'+m}
						else{date = y+'-'+M+'-'+d+' '+h+':'+m}
					}
					else if(str == 'y_md'){
						if(y == ny){date = M+'-'+d}
						else{date = y+'-'+M+'-'+d}
					}
					else if(str == 'ymd'){
						date = y+'-'+M+'-'+d
					}
				}else{date = y+'-'+M+'-'+d+' '+h+':'+m+':'+s}
			}
			return date;
		}
		//日期转换为时间戳
		,dateToTime : function(str){
			var num = ''
			if(str){
				str = str.replace(/\-/g,'/').replace(/\.0/g,'')
				num = new Date(str).getTime();
			}
			return num;
		}

		// 弹出层提示 1.5秒后小时
		,showPopTips : function(str){
			$('.popMid._tips_').show().find('.con').html(str);
			setTimeout(function(){$('.popMid._tips_').hide().find('.con').html('')},1500);
		}

		// 判断是否登录事件
		,isLogin : function(){
			var param = {theUrl : api.user.isLogin, theData : {}}
			doPostAjax(param, this.isLoginFn);
		}
		,isLoginFn : function(data){
			if(data.success == 'true'){
				var ut = data.data.userType, un = data.data.userName || null;
				localStorage.setItem('userType',ut);
				un ? localStorage.setItem('userName',un) : localStorage.removeItem('userName');
				$('.theUserName').html(un);
				(ut == -1) && globalModule.exitFn();  // 退出事件
			}
		}
		,exitFn : function(){
			localStorage.clear();
			sessionStorage.clear();
			localStorage.setItem('userType','-1');
			// 在注册页中保存推荐人ID
			if (getUrlRequest('referId')) localStorage.setItem('referId', getUrlRequest('referId'));

			// $('.typeChose span').removeClass('disabled');
			// 定义设备宽度
			var cw = document.documentElement.clientWidth
				// ,ex = $('.userRegLoginContain').find('.userRegLoginform.ex')
				// ,ed = $('.userRegLoginContain').find('.userRegLoginform.ed')
			;
			if(/\/(website|company)Home/ig.test(location.pathname)){
				if(cw > 768){
					location.href = '/index.html';
				}else{
					// location.href = '/wap/index.html';
					location.href = '/wap/userLoginPg.html';
				}
			}
			else{
				// location.reload();
				// if(ex.hasClass('hide')){ex.removeClass('hide'); ed.addClass('hide')}
			}

		}
		//退出按钮点击事件
		,exit : function(obj){
			obj.on('click',function(){
				$.ajax({
					url: api.user.exit, type: 'POST', cache : false,
					success : function(data){globalModule.exitFn()}
				});
			});
		}

		//--------------------------------------------
		// 显示公告事件 思路：
		// 登录后只请求一次接口
		// 构造noticeData写入缓存
		// 如果noticeData.show为0就不显示 为1就显示
		// 关闭后noticeData.show为0
		//--------------------------------------------
		,showNotice : function(){
			if(this.homeType() == 'all') return;

			this.noticeObj = {};
			// all|company|website
			this.noticeObj.homeType = this.homeType();
			this.noticeObj.area = $('.noticeArea');

			var str = localStorage.NOTICE || '';
			if(!str){
				this.getNoticeList();
			}else{
				this.noticeData = JSON.parse(str);
				this.renderNoticeArea();
			}
		}
		,getNoticeList : function(){
			var param = {theUrl : api.noticeList, theData : {type : this.noticeObj.homeType}};
			doPostAjax(param,this.getNoticeListFn);
		}
		,getNoticeListFn : function(data){
			var _ = globalModule;
			if(data.success == 'true'){
				var data = data.data
					,html = ''
					,link = ''
				;
				//----- 构建notice内容代码 -----
				if(data.title){
					// 判断是否link
					if(data.link){
						if(/^http:\/\//ig.test(data.link)){link = '<a class="noticeLink" href="'+data.link+'" target="_blank">查看详情</a>'}
						else{link = '<a class="noticeLink" href="http://'+data.link+'" target="_blank">查看详情</a>'}
					}
					html =  '<div class="noticeBox"><div class="mainWidth"><div class="noticeContaion">'
								+'<div class="noticeClose">&times;</div>'
								+'<i></i>'
								+'<div class="noticeNr">'
									+'<span class="noticeTxt">'+data.title+'</span>'
									+link
								+'</div>'
							+'</div></div></div>'
					;
				}
				//----- 构建noticeData -----
				_.noticeData = {};
				_.noticeData.show = html ? 1 : 0;
				html ? _.noticeData.html = html : delete _.noticeData.html;
				//----- 写入localStorage -----
				localStorage.setItem('NOTICE',JSON.stringify(_.noticeData));
				//----- 渲染notice区域 -----
				_.renderNoticeArea();
			}else{
				console.log(data.msg);
			}
		}
		,renderNoticeArea : function(){
			// 公告区域清空
			this.noticeObj.area.html('');
			if(this.noticeData.show){
				this.noticeObj.area.html(this.noticeData.html);
				$('.noticeClose').on('click',this.noticeCloseClick);
			}
		}
		// 关闭公告
		,noticeCloseClick : function(){
			var _ = globalModule;
			// notice区域内容为空
			_.noticeObj.area.html('');
			// 设置flag为0，不显示公告
			_.noticeData.show = 0;
			// 删除noticeData的html代码
			delete _.noticeData.html;
			// 写入localStorage
			localStorage.setItem('NOTICE',JSON.stringify(_.noticeData));
		}


		//显示弹框公告
		,showPopNotice : function(){
			var popNoticeArea = $('.popNoticeArea')
				,popNoticeBox = localStorage.getItem('popNoticeBox')  //缓存公告内容
				,popNoticeFlag = localStorage.getItem('popNoticeFlag')  //缓存公告flag
			;
			popNoticeArea.children().remove();  //公告区域清空
			if(!popNoticeFlag){
				popNoticeBox = '<div class="blackCover"><div class="cell"><div class="contain"><div class="whiteArea">'+
									'<div class="popNoticeClose">&times;</div>'+
									'<div class="title">关于“两会”及“315消费者权益日”期间的公告</div>'+
									'<div class="con">'+
										'<span>尊敬的各位用户：</span>'+
										'<span class="p">您们好！</span>'+
										'<span class="p">首先衷心的感谢各位对云自媒的鼎力支持和通力合作。</span>'+
										'<span class="p">受“两会”和“3.15消费者权益日”两项时事热点影响，2017年3月2日至3月16日期间全国类门户网站将主力相关专题追踪报道。预计期间将影响平台的正常接稿、出稿，导致拒单、流单情况高于常规水平。建议广大广告主错峰发布，3月17日后将陆续恢复正常。</span>'+
										'<span class="p">以上造成各位用户的不便，敬请谅解与支持！</span>'+
										'<span>谢谢!</span>'+
										'<span class="r">广州云自媒信息科技有限公司</span>'+
										'<span class="r">2017年3月6日</span>'+
									'</div>'+
								'</div></div></div></div>'
				;
				$(popNoticeBox).appendTo(popNoticeArea);
				localStorage.setItem('popNoticeFlag','1');
				localStorage.setItem('popNoticeBox',popNoticeBox);
				$('.popNoticeClose').on('click',this.popNoticeCloseClick);
			}else if(popNoticeFlag == '1'){
				$(popNoticeBox).appendTo(popNoticeArea);
				$('.popNoticeClose').on('click',this.popNoticeCloseClick);
			}
		}
		,popNoticeCloseClick : function(){
			var parents = $(this).parents('.popNoticeArea');
			parents.children().remove();
			localStorage.removeItem('popNoticeBox');
			localStorage.setItem('popNoticeFlag','0');
		}

		// 显示弹框广告图片
		,popSs : function(){
			if(/\/wap\//ig.test(location.pathname)){return}
			// 向页面写入代码
			var h = '<input type="checkbox" class="none popMid" id="_ss_">'
					+'<div class="popMid _ss_">'
						+'<div class="bg">'
							+'<div class="cell">'
								+'<div class="midBox ss">'
									+'<label class="close black" for="_ss_"></label>'
									+'<div class="zoom"></div>'
								+'</div>'
							+'</div>'
						+'</div>'
					+'</div>'
			;
			$(h).appendTo($('body'));

			var data = {}, param = {};
			if(flagObj.popAdImgFlag == 1){
				var cando = false;
				if(/websiteHome/g.test(pn)){
					if(!flagObj.userInfoFlag){
						data = {type : 'indexAlert_website'}
						cando = true;
					}
				}
				// 广告主
				else if(/companyHome/g.test(pn)){
					if(!flagObj.userInfoFlag && !flagObj.noviceFlag){
						data = {type : 'indexAlert_company'}
						cando = true;
					}
				}
				if(cando){
					param = {theUrl : api.ssList, theData : data}
					doPostAjax(param,this.popSsFn);
				}
			}
		}
		,popSsFn : function(data){
			if(data.success == 'true'){
				if(!data.jsonData.length){return}
				var obj = data.jsonData[0]
					,imgUrl = 'http://'+location.hostname+obj.content || ''
					,w = obj.imgWidth ,h = obj.imgHeight ,per = h / w
					,url = obj.url
					,box = ''
				;
				// 判断是否是有链接
				if(!url || url == '#' || url == ' '){url = ''}else if(/^www./.test(url)){url = 'http://'+url}
				// 如果宽度大于800，则宽度就为800，高度为宽度*百分比
				if(w > 800){w = 800; h = w * per}
				// 定义样式
				var style = ' style="display:block; width:'+w+'px; height:'+h+'px; background:url('+imgUrl+') center; background-size:100% auto;"';
				// 如果URL存在
				url ? box = '<a href="'+url+'" target="_blank"'+style+'></a>' : box = '<span'+style+'></span>';
				$(box).appendTo($('._ss_').find('.zoom'));
				// 将层显示
				$('#_ss_').prop('checked',true);
				// 关闭层点击事件
				$('._ss_').find('.close').on('click',function(){
					localStorage.setItem('popAdImgFlag',0);
				});
			}else{
				console.log(data.msg);
			}
		}

		// 导航菜单激活
		,menuActive : function(){
			var plate = parseInt(getUrlRequest('plate')) || ''
				,platen = '' ,iam = '' ,module = ''
			;
			//如果是首页
			if(pn == '/' || pn == '/index.html'){
				iam = 'index';
				if(!plate){platen = 'index'}
				if(plate == 51){platen = 'article'}
				if(plate == 54){platen = 'client'}
				if(plate == 13){platen = 'wechat'}
				if(plate == 17){platen = 'friend'}
				if(plate == 11){platen = 'weibo'}
				if(plate == 98){platen = 'live'}
				if(plate == 99){platen = 'video'}
			}
			//如果是广告主
			if(/companyHome/g.test(pn)){
				iam = 'adv';
				// article
				if(/(article|paper)(ResList|OrderAdd)|resDealsList|articleDynamicList/g.test(pn)){platen = 'article'}
				// client
				else if(/(client)(ResList|OrderAdd)/g.test(pn)){platen = 'client'}
				// xhs
				else if(/(xhs)(ResList|OrderAdd)/g.test(pn)){platen = 'xhs'}
				// video|live
				// else if(/(video|live)(ResList|OrderAdd)/g.test(pn)){platen = 'video|live'}
				// video
				else if(/(video)(Res(List|View)|OrderAdd)/g.test(pn)){platen = 'video'}
				// live
				else if(/(live)(ResList|OrderAdd)/g.test(pn)){platen = 'live'}
				// wechat
				else if(/(wechat)(ResList|OrderAdd)/g.test(pn) || (/starResList/g.test(pn) && plate == 13)){platen = 'wechat'}
				// friend
				else if(/(friend)(ResList|OrderAdd)/g.test(pn) || (/starResList/g.test(pn) && plate == 17)){platen = 'friend'}
				// weibo
				else if(/(weibo)(ResList|OrderAdd)/g.test(pn) || (/starResList/g.test(pn) && plate == 11)){platen = 'weibo'}
				// recharge
				else if(/recharge/g.test(pn)){platen = 'recharge'}
				// userProfile
				else if(/user|((article|wechat|friend|weibo|video|live|paper|star)OrderList)|((bill|adArticle|resQuote|resBlack)List)|adArticleAdd/g.test(pn)){platen = 'userProfile'}
			}
			//如果是媒介主
			if(/websiteHome/g.test(pn)){
				iam = 'media';
				if(/userProfile/g.test(pn)){platen = 'index'}
				if(/order/ig.test(pn)){platen = 'order'}
				if(/Res(List|Add)|Check/g.test(pn)){platen = 'res'}
				if(/billList/g.test(pn)){platen = 'billList'}
			}
			$('.header .menu-'+iam).find('a').each(function(){
				if($(this).data('plate') == platen){$(this).addClass('active')}
			});
		}

		// 弹出层关闭按钮点击事件
		,closePopLayer : function(btn){
			btn.on('click',function(){
				loading.fadeOut();
			});
		}

	}
})();

var _PLATE_ = _PLATE_ || {};
_PLATE_ = (function(){
	var pn = location.pathname;
	return {
		plate : function(){
			var n = '';
			if(/article/ig.test(pn)){n = /pxy/ig.test(pn) ? 53 : 51}
			else if(/friend/g.test(pn)){n = 17}
			else if(/wechat/g.test(pn)){n = 13}
			else if(/weibo/g.test(pn)){n = 11}
			else if(/paper/g.test(pn)){n = 20}
			else if(/live/g.test(pn)){n = 98}
			else if(/video/g.test(pn)){n = 99}
			else if(/xhs/g.test(pn)){n = 94}
			else if(/star/g.test(pn)){n = 30}
			else if(/client/g.test(pn)){n = 54}
			else{
				if(getUrlRequest('plate')){n = Number(getUrlRequest('plate'))}
				else if(getUrlRequest('platen')){
					if(getUrlRequest('platen') == 'wechat'){n = 13}
					else if(getUrlRequest('platen') == 'friend'){n = 17}
					else if(getUrlRequest('platen') == 'weibo'){n = 11}
					else if(getUrlRequest('platen') == 'client'){n = 54}
				}
			}
			return n;
		}
		,platen : function(){
			var str = '';
			if(/article/g.test(pn)){
				if(/pxy/ig.test(pn)){str = 'pxyarticle'}
				else{str = 'article'}
			}
			else if(/wechatCheck/g.test(pn)){str = 'wechatCheck'}
			else if(/weiboCheck/g.test(pn)){str = 'weiboCheck'}
			else if(/client/g.test(pn)){str = 'client'}
			else if(/friend/g.test(pn)){str = 'friend'}
			else if(/wechat/g.test(pn)){str = 'wechat'}
			else if(/weibo/g.test(pn)){str = 'weibo'}
			else if(/paper/g.test(pn)){str = 'paper'}
			else if(/live/g.test(pn)){str = 'live'}
			else if(/video/g.test(pn)){str = 'video'}
			else if(/xhs/g.test(pn)){str = 'xhs'}
			else if(/star/g.test(pn)){str = 'star'}
			else{
				if(getUrlRequest('plate') == 13 || getUrlRequest('platen') == 'wechat'){str = 'wechat'}
				else if(getUrlRequest('plate') == 17 || getUrlRequest('platen') == 'friend'){str = 'friend'}
				else if(getUrlRequest('plate') == 11 || getUrlRequest('platen') == 'weibo'){str = 'weibo'}
				else if(getUrlRequest('plate') == 54 || getUrlRequest('platen') == 'client'){str = 'client'}
			}
			return str;
		}
		,subPlate : function(){
			var n = 0;
			if(/star/g.test(pn) && getUrlRequest('plate')){n = getUrlRequest('plate')}
			return n;
		}
	}
})();


//正则表达式
var reg = {
	url : /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/
	,numEmail : /[0-9]{6,}|([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)/g
	,price : /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
	// ,alipay : /^(13|15|18|14|17)[0-9]{9}$|^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
	// ,alipay : /^1[3-8]{1}[0-9]{9}$|^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
	,alipay : /^1[0-9]{10}$|^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
	,enNum : /^[A-Za-z0-9]+$|^[A-Za-z0-9]{4,40}$/
	,email : /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
	,cnen1 : /^[a-zA-Z\u4e00-\u9fa5]{1,20}$/
	,cnen2 : /^[a-zA-Z\u4e00-\u9fa5]{2,20}$/
	// ,mobile : /^(13|15|18|14|17)[0-9]{9}$/
	// ,mobile : /^1[3-8]{1}[0-9]{9}$/
	,mobile : /^1[0-9]{10}$/
	,cn : /[\u4E00-\u9FA5]/
	,qq : /^[0-9]{5,11}$/
	,sms : /^[0-9]{6}$/
	,num : /^[0-9]*$/
	,numg : /[0-9]/g
	,blank : /\s/
	,wechat : /微信|wx|weixin|wechat/g
};

//----------操作Cookies----------
var cookie = (function(){
	return {
		//设置cookie方法
		set : function(key,val,time){
			var date = new Date(); //获取当前时间
			var expiresDays = time;  //将date设置为n天以后的时间
			date.setTime(date.getTime()+expiresDays*24*3600*1000); //格式化为cookie识别的时间
			document.cookie = key +'='+ val +";expires="+ date.toGMTString();  //设置cookie
		}
		//获取cookie方法
		,get : function(key){
			/*获取cookie参数*/
			var getCookie = document.cookie.replace(/[ ]/g,'');  //获取cookie，并且将获得的cookie格式化，去掉空格字符
			var arrCookie = getCookie.split(';')  //将获得的cookie以"分号"为标识 将cookie保存到arrCookie的数组中
			var tips;  //声明变量tips
			for(var i=0; i<arrCookie.length; i++){   //使用for循环查找cookie中的tips变量
				var arr=arrCookie[i].split('=');   //将单条cookie用"等号"为标识，将单条cookie保存为arr数组
				if(key==arr[0]){  //匹配变量名称，其中arr[0]是指的cookie名称，如果该条变量为tips则执行判断语句中的赋值操作
					tips=arr[1];   //将cookie的值赋给变量tips
					break;   //终止for循环遍历
				}
			}
			return tips;
		}
		//删除cookie方法
		,deletes : function(key){
			var date = new Date()
				,times = date.getTime()
				,st = times - 10000
			;
			date.setTime(st); //将date设置为过去的时间
			document.cookie = key +'=v; expires ='+ date.toGMTString();//设置cookie
		}
		//调用方法
		//cookie.set("uesr","sss",24); 设置为24天过期
		//cookie.get("uesr") 获取cooikes
		//cookie.delete("uesr") 删除cooikes
	}
})();


//---------- 公用AJAX调用 ----------
function doPostAjax(param,callback,vars){
	$.ajax({
		type : 'POST',
		url : param.theUrl,
		data : param.theData,
		cache : false,
		success : function(data){callback(data,vars)}
	});
}
function doGetAjax(param,callback,vars){
	$.ajax({
		// type : 'GET',
		type : 'POST',
		url : param.theUrl,
		data : param.theData,
		cache : false,
		success :function(data){callback(data,vars)}
	});
}



//---------- 获取url上的参数 ----------
function getUrlRequest(n) {
	var reg = new RegExp('(^|&)'+n+'=([^&]*)(&|$)', 'i'),
		os = window.location.search.substr(1),
		r = os.match(reg);
	if(r){return unescape(r[2])}
	else{return ''}
}
//---------- 提示初始 ----------
function tipsReset(input){
	input.removeClass('error').next('i').removeClass('error').removeClass('ok').html('');
}
//---------- 提示错误 ----------
function tipsError(input,tips){
	input.addClass('error').next('i').removeClass('ok').addClass('error').html(tips);
}
//---------- 提示正确 ----------
function tipsOk(input){
	input.removeClass('error').next('i').removeClass('error').addClass('ok').html('');
}


// alert
var _ALERT_ = _ALERT_ || {};
_ALERT_ = (function(){
	return {
		init : function(str){
			if (!str) return;
			$('.popMid._alert_').find('.con').html(str);
			$('#_alert_').prop('checked',true);
		}
	}
}());

// pop tip
var _POPTIP_ = _POPTIP_ || {};
_POPTIP_ = (function(){
	return {
		init : function(str){
			if (!str) return;
			$('.popMid._tips_').show().find('.con').html(str);
			setTimeout(function(){
				$('.popMid._tips_').hide().find('.con').html('');
			},1000);
		}
	}
}());




